package com.mokylin.dbschema.handler;

import com.mokylin.dbschema.config.ConfigInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author 李朝(Li.Zhao)
 * @since 2015/8/31.
 */

public class SqlVersionHandlerFactory {

    private static final Logger LOG = LoggerFactory.getLogger(SqlVersionHandlerFactory.class);

    private static SqlVersionHandler sqlVersionHandler;

    public static SqlVersionHandler getSqlVersionHandler(){
        if(sqlVersionHandler!=null){
            return sqlVersionHandler;
        }
        String handler = ConfigInfo.getSqlVersionHandler();
        try {
            return sqlVersionHandler = (SqlVersionHandler) Class.forName(handler).newInstance();
        } catch (Exception e) {
            LOG.error(e.getMessage(),e);
        }
        return null;
    }
}